package com.totoro.tymapping.enums;

import com.totoro.tymapping.constants.ComputeConst;
import com.totoro.tymapping.executor.compute.ComputeExecutor;
import com.totoro.tymapping.executor.compute.impl.EvalExecutor;

/**
 * @author Totoro
 * @version 0.1.0
 * @date 2025/8/13 - 17:15
 * @description 计算执行器枚举
 **/
public enum ComputeExecutorEnum {
    EVAL(ComputeConst.EVAL, new EvalExecutor());

    private String computeType;
    private ComputeExecutor computeExecutor;

    ComputeExecutorEnum(String computeType, ComputeExecutor computeExecutor) {
        this.computeType = computeType;
        this.computeExecutor = computeExecutor;
    }

    public static ComputeExecutor getComputeExecutor(String compute) {
        for (ComputeExecutorEnum value : ComputeExecutorEnum.values()) {
            if (compute.contains(value.computeType)) {
                return value.computeExecutor;
            }
        }
        return null;
    }
}
